#----------------------11号楼机房------------
import requests

def get_datacenter_11haolou_data():
    # 登录验证接口
    login_url = "http://x.x.x.x:1026/Login"

    # 其他接口获取数据
    #实时数据接口
    curr_data_url = "http://x.x.x.x:1026/GetDevicePropertiesInPage"
    #告警接口
    alarm_url = "http://x.x.x.x:1026/GetRealAlarms"
    # 登录信息
    username = "xxxxxxxxxxxxxxxx"
    password = "xxxxxxxxxxxxxxxxxxxxxx"

    # 发送登录请求
    login_response = requests.post(login_url, headers={"User-Name": username, "Password": password})

    # alarm_body = {
    #     "serverCode":"zgkon",
    #     "userId":0
    # }
    headers = {
        "User-Name": username,
        "Password": password
    }

    # 检查登录是否成功
    if login_response.status_code == 200:
        print("登录成功！")
        #获取11号楼动环告警
        alarm_response = requests.post(alarm_url, json={"serverCode": "zgkon","userId": 0}, headers=headers)
        if alarm_response.status_code == 200:
            alarm_response_json = alarm_response.json()
            if len(alarm_response_json) > 0:
                alarm_value_shuzu = []
                alarm_value = ""
                for alarm_data in alarm_response_json:
                    alarm_data_name = alarm_data.get("alarmName")
                    alarm_data_time = alarm_data.get("alarmDateTime")
                    alarm_data_value = alarm_data.get("alarmValue")
                    alarm_value_shuzu.append(f"{alarm_data_time} &nbsp,&nbsp {alarm_data_name}, &nbsp当前值为：  {alarm_data_value}")
                for i in alarm_value_shuzu:
                    alarm_value += str(i) + "<br>"
                print(alarm_value)

            else:
                alarm_value = "当前无告警"
        else:
            print("获取数据失败")


        #获取11号楼消防主机数据
        data_response = requests.post(curr_data_url, json={"serverCode": "zgkon","userId": 0, "pageId": 31}, headers=headers)
        if data_response.status_code == 200:
            data_response_json = data_response.json()
            if len(data_response_json) > 1:  # 确保数据长度大于1，避免索引错误
                beixiaofangzhuji = data_response_json[0]['devicePropertyName']
                a = data_response_json[0]['status']
                if a == 0:
                    beixiaofangzhuji_status = "北侧机房消防主机无告警"

                nanxiaofangzhuji = data_response_json[1]['devicePropertyName']

                b = data_response_json[1]['status']
                if b == 0:
                    nanxiaofangzhuji_status = "南侧机房消防主机无告警"

                #print(f"北消防主机名称及状态：{beixiaofangzhuji} {beixiaofangzhuji_status}")
               # print(f"南消防主机名称及状态：{nanxiaofangzhuji} {nanxiaofangzhuji_status}")
        else:
            print("获取消防主机数据失败！")

        #获取11号楼南侧机房 A-ups信息
        UPSA_response = requests.post(curr_data_url, json={"serverCode": "zgkon","userId": 0, "pageId": 21}, headers=headers)
        if UPSA_response.status_code == 200:
            UPSA_response_json = UPSA_response.json()
            if len(UPSA_response_json) > 1:  # 确保数据长度大于1，避免索引错误
                #UPSA供电状态 市电供电/电池供电
                #UPSA_gdzt = UPSA_response_json[67]['devicePropertyName']
                UPSA_gdzt_shidian = UPSA_response_json[69]['currentValue']
                print(UPSA_gdzt_shidian)
                UPSA_gdzt_panglu = UPSA_response_json[68]['currentValue']
                print(UPSA_gdzt_panglu)
                UPSA_gdzt_dianchi = UPSA_response_json[70]['currentValue']
                print(UPSA_gdzt_dianchi)
                UPSA_gdzt_no = UPSA_response_json[67]['currentValue']
                print(UPSA_gdzt_no)
                if UPSA_gdzt_shidian == 1 and UPSA_gdzt_panglu == 0 and UPSA_gdzt_dianchi == 0 and UPSA_gdzt_no == 0:
                    UPSA_gdzt_value = "市电供电"
                if UPSA_gdzt_shidian == 0 and UPSA_gdzt_panglu == 1 and UPSA_gdzt_dianchi == 0 and UPSA_gdzt_no == 0:
                    UPSA_gdzt_value = "旁路供电"
                if UPSA_gdzt_shidian == 0 and UPSA_gdzt_panglu == 0 and UPSA_gdzt_dianchi == 1 and UPSA_gdzt_no == 0:
                    UPSA_gdzt_value = "电池供电"
                if UPSA_gdzt_shidian == 0 and UPSA_gdzt_panglu == 0 and UPSA_gdzt_dianchi == 0 and UPSA_gdzt_no == 1:
                    UPSA_gdzt_value = "均不供电"

                print(f"供电状态: {UPSA_gdzt_value}")

                #UPSA 备电时间
                UPSA_bdsj_value = UPSA_response_json[65]['currentValue']
                print(f"备电时间: {UPSA_bdsj_value}")
                #UPSA 电池电压
                UPSA_dcdy_value = UPSA_response_json[63]['currentValue']
                print(f"电池电压: {UPSA_dcdy_value}")
                #锂电池寿命
                # UPSA_ldsm_value = UPSA_response_json[63]['currentValue']
                # print(f"电池电压: {UPSA_dcdy_value}")
                # UPSA 剩余容量
                UPSA_syrl_value = UPSA_response_json[66]['currentValue']
                print(f"剩余容量: {UPSA_syrl_value}")

                # print(f"北消防主机名称及状态：{beixiaofangzhuji} {beixiaofangzhuji_status}")
            # print(f"南消防主机名称及状态：{nanxiaofangzhuji} {nanxiaofangzhuji_status}")
        else:
            print("获取11号楼南侧机房 A-ups数据失败！")

        # 获取11号楼南侧机房 B-ups信息
        UPSB_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 24}, headers=headers)
        if UPSB_response.status_code == 200:
            UPSB_response_json = UPSB_response.json()
            if len(UPSB_response_json) > 1:  # 确保数据长度大于1，避免索引错误

                # UPSB供电状态 市电供电/电池供电

                UPSB_gdzt_shidian = UPSB_response_json[69]['currentValue']
                print(UPSB_gdzt_shidian)
                UPSB_gdzt_panglu = UPSB_response_json[68]['currentValue']
                print(UPSB_gdzt_panglu)
                UPSB_gdzt_dianchi = UPSB_response_json[70]['currentValue']
                print(UPSB_gdzt_dianchi)
                UPSB_gdzt_no = UPSB_response_json[67]['currentValue']
                print(UPSB_gdzt_no)
                if UPSB_gdzt_shidian == 1 and UPSB_gdzt_panglu == 0 and UPSB_gdzt_dianchi == 0 and UPSB_gdzt_no == 0:
                    UPSB_gdzt_value = "市电供电"
                if UPSB_gdzt_shidian == 0 and UPSB_gdzt_panglu == 1 and UPSB_gdzt_dianchi == 0 and UPSB_gdzt_no == 0:
                    UPSB_gdzt_value = "旁路供电"
                if UPSB_gdzt_shidian == 0 and UPSB_gdzt_panglu == 0 and UPSB_gdzt_dianchi == 1 and UPSB_gdzt_no == 0:
                    UPSB_gdzt_value = "电池供电"
                if UPSB_gdzt_shidian == 0 and UPSB_gdzt_panglu == 0 and UPSB_gdzt_dianchi == 0 and UPSB_gdzt_no == 1:
                    UPSB_gdzt_value = "均不供电"
                print(f"11号楼UPSB")
                print(f"供电状态: {UPSB_gdzt_value}")

                # UPSB 备电时间
                UPSB_bdsj_value = UPSB_response_json[65]['currentValue']
                print(f"备电时间: {UPSB_bdsj_value}")
                # UPSB 电池电压
                UPSB_dcdy_value = UPSB_response_json[63]['currentValue']
                print(f"电池电压: {UPSB_dcdy_value}")
                # 锂电池寿命
                # UPSB_ldsm_value = UPSB_response_json[63]['currentValue']
                # print(f"电池电压: {UPSB_dcdy_value}")
                # UPSB 剩余容量
                UPSB_syrl_value = UPSB_response_json[66]['currentValue']
                print(f"剩余容量: {UPSB_syrl_value}")
        else:
            print("获取11号楼南侧机房 B-ups数据失败！")



        # 获取11号楼北侧机房UPS 信息
        UPS_beice_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 27}, headers=headers)
        if UPS_beice_response.status_code == 200:
            UPS_beice_response_json = UPS_beice_response.json()
            if len(UPS_beice_response_json) > 1:  # 确保数据长度大于1，避免索引错误
                # UPS_beice供电状态 市电供电/电池供电
                UPS_beice_gdzt_shidian = UPS_beice_response_json[69]['currentValue']
                print(UPS_beice_gdzt_shidian)
                UPS_beice_gdzt_panglu = UPS_beice_response_json[68]['currentValue']
                print(UPS_beice_gdzt_panglu)
                UPS_beice_gdzt_dianchi = UPS_beice_response_json[70]['currentValue']
                print(UPS_beice_gdzt_dianchi)
                UPS_beice_gdzt_no = UPS_beice_response_json[67]['currentValue']
                print(UPS_beice_gdzt_no)
                if UPS_beice_gdzt_shidian == 1 and UPS_beice_gdzt_panglu == 0 and UPS_beice_gdzt_dianchi == 0 and UPS_beice_gdzt_no == 0:
                    UPS_beice_gdzt_value = "市电供电"
                if UPS_beice_gdzt_shidian == 0 and UPS_beice_gdzt_panglu == 1 and UPS_beice_gdzt_dianchi == 0 and UPS_beice_gdzt_no == 0:
                    UPS_beice_gdzt_value = "旁路供电"
                if UPS_beice_gdzt_shidian == 0 and UPS_beice_gdzt_panglu == 0 and UPS_beice_gdzt_dianchi == 1 and UPS_beice_gdzt_no == 0:
                    UPS_beice_gdzt_value = "电池供电"
                if UPS_beice_gdzt_shidian == 0 and UPS_beice_gdzt_panglu == 0 and UPS_beice_gdzt_dianchi == 0 and UPS_beice_gdzt_no == 1:
                    UPS_beice_gdzt_value = "均不供电"
                print(f"11号楼UPS_beice")
                print(f"供电状态: {UPS_beice_gdzt_value}")

                # UPS_beice 备电时间
                UPS_beice_bdsj_value = UPS_beice_response_json[65]['currentValue']
                print(f"备电时间: {UPS_beice_bdsj_value}")
                # UPS_beice 电池电压
                UPS_beice_dcdy_value = UPS_beice_response_json[63]['currentValue']
                print(f"电池电压: {UPS_beice_dcdy_value}")
                # 锂电池寿命
                # UPS_beice_ldsm_value = UPS_beice_response_json[63]['currentValue']
                # print(f"电池电压: {UPS_beice_dcdy_value}")
                # UPS_beice 剩余容量
                UPS_beice_syrl_value = UPS_beice_response_json[66]['currentValue']
                print(f"剩余容量: {UPS_beice_syrl_value}")
        else:
            print("获取11号楼北侧机房ups数据失败！")

        #获取11号楼北侧机房电池柜SOH
        dianchi_beice_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 1},
                                               headers=headers)
        if dianchi_beice_response.status_code == 200:
            dianchi_beice_response_json = dianchi_beice_response.json()
            if len(dianchi_beice_response_json) > 1:  # 确保数据长度大于1，避免索引错误

                # dianchi_beice 电池SOH
                dianchi_beice_soh_value = dianchi_beice_response_json[2]['currentValue']
                print(f"北侧机房电池SOH: {dianchi_beice_soh_value}")

        else:
            print("获取11号楼北侧机房电池数据失败！")
        # 获取11号楼南侧机房UPS-A电池柜 SOH
        dianchi_nance_A_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 2},
                                                 headers=headers)
        if dianchi_nance_A_response.status_code == 200:
            dianchi_nance_A_response_json = dianchi_nance_A_response.json()
            if len(dianchi_nance_A_response_json) > 1:  # 确保数据长度大于1，避免索引错误

                # dianchi_nance_A 电池SOH
                dianchi_nance_A_soh_value = dianchi_nance_A_response_json[2]['currentValue']
                print(f"南侧机房UPSA——电池柜SOH: {dianchi_nance_A_soh_value}")
        else:
            print("获取11号楼北侧机房电池数据失败！")

        # 获取11号楼南侧机房UPS-B电池柜 SOH
        dianchi_nance_B_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 4},
                                                 headers=headers)
        if dianchi_nance_B_response.status_code == 200:
            dianchi_nance_B_response_json = dianchi_nance_B_response.json()
            if len(dianchi_nance_B_response_json) > 1:  # 确保数据长度大于1，避免索引错误
                # dianchi_nance_B 电池SOH
                dianchi_nance_B_soh_value = dianchi_nance_B_response_json[2]['currentValue']
                print(f"南侧机房UPSB——电池柜SOH: {dianchi_nance_B_soh_value}")
        else:
            print("获取11号楼北侧机房电池数据失败！")

        # 获取11号楼南侧机房空调温度设定值
        nckt_wdsd_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 15},
                                           headers=headers)
        if nckt_wdsd_response.status_code == 200:
            nckt_wdsd_response_json = nckt_wdsd_response.json()
            if len(nckt_wdsd_response_json) > 1:  # 确保数据长度大于1，避免索引错误
                nckt_wdsd_value = nckt_wdsd_response_json[26]['currentValue']
                print(f"南侧机房空调温度设定值: {nckt_wdsd_value}")
        else:
            print("获取11号楼南侧机房空调温度设定值失败")

        # 获取11号楼北侧机房空调温度设定值
        bckt_wdsd_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 19},
                                           headers=headers)
        if bckt_wdsd_response.status_code == 200:
            bckt_wdsd_response_json = bckt_wdsd_response.json()
            if len(bckt_wdsd_response_json) > 1:  # 确保数据长度大于1，避免索引错误
                bckt_wdsd_value = bckt_wdsd_response_json[60]['currentValue']
                print(f"北侧机房空调温度设定值: {bckt_wdsd_value}")
        else:
            print("获取11号楼北侧机房空调温度设定值失败")


        # 获取11号楼南侧机房温湿度
        wsd_nance_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 20},
                                               headers=headers)
        if wsd_nance_response.status_code == 200:
            wsd_nance_response_json = wsd_nance_response.json()
            # if len(wsd_nance_response_json) > 1:  # 确保数据长度大于1，避免索引错误
            #
            #      # wsd_nance 南侧机房温湿度
            #     wsd_nance_soh_value = wsd_nance_response_json[2]['currentValue']
            #     print(f"南侧机房UPSB——电池柜SOH: {wsd_nance_soh_value}")
            # else:
            #     print("获取11号楼北侧机房电池数据失败！")
            #print("-----------------------------------------------------")
            wsd = []
            for wsd_data in wsd_nance_response_json:
                wsd_value = wsd_data.get("currentValue")
                wsd.append(wsd_value)
            wd = []
            sd = []
            for i in range(len(wsd)):
                if i % 2 == 0:
                    wd.append(wsd[i])
                else:
                    sd.append(wsd[i])

            max_wd = round(max(wd),2)
            if max_wd > 26:
                max_wd = f'<span style="color:red;">{max_wd}</span>'
            else:
                max_wd = f'<span style="color:green;">{max_wd}</span>'
            print(f"最大温度:{max_wd}")
            avg_wd = round(sum(wd) / len(wd),2)
            if avg_wd > 25:
                avg_wd = f'<span style="color:red;">{avg_wd}</span>'
            else:
                avg_wd = f'<span style="color:green;">{avg_wd}</span>'
            print(f"平均温度:{avg_wd}")
            max_sd = round(max(sd),2)
            if max_sd > 70:
                max_sd = f'<span style="color:red;">{max_sd}</span>'
            else:
                max_sd = f'<span style="color:green;">{max_sd}</span>'
            print(f"最大温度:{max_sd}")
            avg_sd = round(sum(sd) / len(sd),2)
            if avg_sd > 50:
                avg_sd = f'<span style="color:red;">{avg_sd}</span>'
            else:
                avg_sd = f'<span style="color:green;">{avg_sd}</span>'
            print(f"平均温度:{avg_sd}")
        else:
            print("获取11号楼南侧机房温湿度失败")

        # ------------------------电池组信息
        # 实时数据接口
        curr_data_url = "http://10.106.134.153:1026/GetDevicePropertiesInPage"

        # 登录信息
        username = "admin"
        password = "Dh!.134qte0"

        headers = {
            "User-Name": username,
            "Password": password
        }

        # 获取1号楼机房A模块1-32节蓄电池最小电压、编号、内阻
        xdc_A_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 32},
                                       headers=headers)
        if xdc_A_response.status_code == 200:
            xdc_A_response_json = xdc_A_response.json()
            xdc_A_32_dict = xdc_A_response_json[:32]  # 取列表的前32个字典
            xdc_A_32_min_v = float('inf')  # 定义电压变量为无穷大浮点数
            for data in xdc_A_32_dict:  # 对比电压最小值
                if data['currentValue'] < xdc_A_32_min_v:
                    xdc_A_32_min_v = data['currentValue']  # 获取最小电压数值
                    xdc_A_32_min_name = data.get('devicePropertyName')  # 获取最小电压的电池名称
                    xdc_A_32_min_sn = data.get('devicePropertyId')  # 获取最小电压的字典Id

            xdc_A_32_new = int(xdc_A_32_min_sn[-4:]) + 128  # Id后4位加128运算
            xdc_A_32_min_dz = xdc_A_32_min_sn[:-4] + format(xdc_A_32_new)  # 获取最小电压对应电池的阻值的字典Id
            xdc_A_32_min_list_dz = [d for d in xdc_A_response_json if
                                    d.get('devicePropertyId') == xdc_A_32_min_dz]  # 找到最小电压对应的数列
            xdc_A_32_min_dict_dz = xdc_A_32_min_list_dz[0]  # 转换为字典
            xdc_A_32_min_v_sn = xdc_A_32_min_name[:6]
            xdc_A_32_min_v_dz = xdc_A_32_min_dict_dz.get('currentValue')
            print(f"{xdc_A_32_min_v},{xdc_A_32_min_v_sn},{xdc_A_32_min_v_dz}")
            # 获取1号楼机房A模块33-64节蓄电池最小电压、编号、内阻
            xdc_A_64_dict = xdc_A_response_json[32:64]  # 取列表的第33~64个字典
            xdc_A_64_min_v = float('inf')  # 定义电压变量为无穷大浮点数
            for data2 in xdc_A_64_dict:  # 对比电压最小值
                if data2['currentValue'] < xdc_A_64_min_v:
                    xdc_A_64_min_v = data2['currentValue']  # 获取最小电压数值
                    xdc_A_64_min_name = data2.get('devicePropertyName')  # 获取最小电压的电池名称
                    xdc_A_64_min_sn = data2.get('devicePropertyId')  # 获取最小电压的字典Id
            xdc_A_64_new = int(xdc_A_64_min_sn[-4:]) + 128  # Id后4位加128运算
            xdc_A_64_min_dz = xdc_A_64_min_sn[:-4] + format(xdc_A_64_new)  # 获取最小电压对应电池的阻值的字典Id
            xdc_A_64_min_list_dz = [d2 for d2 in xdc_A_response_json if
                                    d2.get('devicePropertyId') == xdc_A_64_min_dz]  # 找到最小电压对应的数列
            xdc_A_64_min_dict_dz = xdc_A_64_min_list_dz[0]  # 转换为字典
            xdc_A_64_min_v_sn = xdc_A_64_min_name[:6]
            xdc_A_64_min_v_dz = xdc_A_64_min_dict_dz.get('currentValue')
            print(f"{xdc_A_64_min_v},{xdc_A_64_min_v_sn},{xdc_A_64_min_v_dz}")
            # 获取1号楼机房A模块1-32节蓄电池最大内阻、编号、电压
            xdc_A_160_dict = xdc_A_response_json[128:160]  # 取列表的第129~160个字典
            xdc_A_160_min_dz = float('-inf')  # 定义内阻变量为无穷大负浮点数
            for data3 in xdc_A_160_dict:  # 对比电压最小值
                if data3['currentValue'] > xdc_A_160_min_dz:
                    xdc_A_160_min_dz = data3['currentValue']  # 获取最大内阻数值
                    xdc_A_160_min_name = data3.get('devicePropertyName')  # 获取最小电压的电池名称
                    xdc_A_160_min_sn = data3.get('devicePropertyId')  # 获取最小电压的字典Id
            xdc_A_160_new = int(xdc_A_160_min_sn[-4:]) - 128  # Id后4位加128运算
            xdc_A_160_min_v = xdc_A_160_min_sn[:-4] + format(xdc_A_160_new)  # 获取最大阻值对应电池的电压字典Id
            xdc_A_160_min_list_v = [d3 for d3 in xdc_A_response_json if
                                    d3.get('devicePropertyId') == xdc_A_160_min_v]  # 找到最大阻值对应的数列
            xdc_A_160_min_dict_v = xdc_A_160_min_list_v[0]  # 转换为字典
            xdc_A_160_min_dz_sn = xdc_A_160_min_name[:6]
            xdc_A_160_min_dz_v = xdc_A_160_min_dict_v.get('currentValue')
            print(f"{xdc_A_160_min_dz},{xdc_A_160_min_dz_sn},{xdc_A_160_min_dz_v}")
            # 获取1号楼机房A模块33-64节蓄电池最大内阻、编号、电压
            xdc_A_192_dict = xdc_A_response_json[160:192]  # 取列表的第129~160个字典
            xdc_A_192_min_dz = float('-inf')  # 定义内阻变量为无穷大负浮点数
            for data4 in xdc_A_192_dict:  # 对比电压最小值
                if data4['currentValue'] > xdc_A_192_min_dz:
                    xdc_A_192_min_dz = data4['currentValue']  # 获取最大内阻数值
                    xdc_A_192_min_name = data4.get('devicePropertyName')  # 获取最小电压的电池名称
                    xdc_A_192_min_sn = data4.get('devicePropertyId')  # 获取最小电压的字典Id
            xdc_A_192_new = int(xdc_A_192_min_sn[-4:]) - 128  # Id后4位加128运算
            xdc_A_192_min_v = xdc_A_192_min_sn[:-4] + format(xdc_A_192_new)  # 获取最大阻值对应电池的电压字典Id
            xdc_A_192_min_list_v = [d4 for d4 in xdc_A_response_json if
                                    d4.get('devicePropertyId') == xdc_A_192_min_v]  # 找到最大阻值对应的数列
            xdc_A_192_min_dict_v = xdc_A_192_min_list_v[0]  # 转换为字典
            xdc_A_192_min_dz_sn = xdc_A_192_min_name[:6]
            xdc_A_192_min_dz_v = xdc_A_192_min_dict_v.get('currentValue')
            print(f"{xdc_A_192_min_dz},{xdc_A_192_min_dz_sn},{xdc_A_192_min_dz_v}")
        else:
            print("获取101室A模块1~64节电池状态失败！")

        # 实时数据接口
        curr_data_url = "http://10.106.134.153:1026/GetDevicePropertiesInPage"

        # 登录信息
        username = "admin"
        password = "Dh!.134qte0"

        headers = {
            "User-Name": username,
            "Password": password
        }

        # 获取1号楼机房B模块1-40节蓄电池电压、温度、内阻
        xdc_B_1_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 33},
                                         headers=headers)
        xdc_B_1_shuzu_all = []
        xdc_B_1_response_json = xdc_B_1_response.json()
        for a in xdc_B_1_response_json:
            xdc_B_1_shuzu_all.append(a['currentValue'])

        # 1号楼101机房B模块1-40节蓄电池电压
        xdc_B_1_shuzu_dianya = xdc_B_1_shuzu_all[0:40]
        # 1号楼101机房B模块1-40节蓄电池最低电压、索引、最低电压电池编号
        xdc_B_1_mini_dianya_value_with_index = min((value, index) for index, value in enumerate(xdc_B_1_shuzu_dianya))
        xdc_B_1_mini_dianya_value = xdc_B_1_mini_dianya_value_with_index[0]
        xdc_B_1_mini_dianya_index = xdc_B_1_mini_dianya_value_with_index[1]
        xdc_B_1_mini_dianya_dc_name = xdc_B_1_response_json[xdc_B_1_mini_dianya_index]['devicePropertyName']
        xdc_B_1_mini_dianya_neizu = xdc_B_1_response_json[xdc_B_1_mini_dianya_index + 80]['currentValue']
        xdc_B_1_mini_dianya_sn = xdc_B_1_mini_dianya_dc_name[:6]
        print(f"{xdc_B_1_mini_dianya_value}，{xdc_B_1_mini_dianya_sn}，{xdc_B_1_mini_dianya_neizu}")

        # 1号楼101机房B模块1-40节蓄电池内阻
        xdc_B_1_shuzu_neizu = xdc_B_1_shuzu_all[80:120]
        # 1号楼101机房B模块1-40节蓄电池最大内阻、索引、最低电压电池编号
        xdc_B_1_max_neizu_value_with_index = max((value, index) for index, value in enumerate(xdc_B_1_shuzu_neizu))
        xdc_B_1_max_neizu_value = xdc_B_1_max_neizu_value_with_index[0]
        xdc_B_1_max_neizu_index = xdc_B_1_max_neizu_value_with_index[1]
        xdc_B_1_max_neizu_dc_name = xdc_B_1_response_json[xdc_B_1_max_neizu_index + 80]['devicePropertyName']
        xdc_B_1_max_neizu_dc_dianya = xdc_B_1_response_json[xdc_B_1_max_neizu_index]['currentValue']
        xdc_B_1_max_neizu_sn = xdc_B_1_max_neizu_dc_name[:6]
        print(f"{xdc_B_1_max_neizu_value}，{xdc_B_1_max_neizu_sn},{xdc_B_1_max_neizu_dc_dianya}")

        # 实时数据接口
        curr_data_url = "http://10.106.134.153:1026/GetDevicePropertiesInPage"

        # 登录信息
        username = "admin"
        password = "Dh!.134qte0"

        headers = {
            "User-Name": username,
            "Password": password
        }

        # 获取1号楼机房B模块41-80节蓄电池电压、温度、内阻
        xdc_B_2_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 34},
                                         headers=headers)
        xdc_B_2_shuzu_all = []
        xdc_B_2_response_json = xdc_B_2_response.json()
        for a in xdc_B_2_response_json:
            xdc_B_2_shuzu_all.append(a['currentValue'])

        # 1号楼101机房B模块41-80节蓄电池电压
        xdc_B_2_shuzu_dianya = xdc_B_2_shuzu_all[0:40]
        # 1号楼101机房B模块41-80节蓄电池最低电压、索引、最低电压电池编号
        xdc_B_2_mini_dianya_value_with_index = min((value, index) for index, value in enumerate(xdc_B_2_shuzu_dianya))
        xdc_B_2_mini_dianya_value = xdc_B_2_mini_dianya_value_with_index[0]
        xdc_B_2_mini_dianya_index = xdc_B_2_mini_dianya_value_with_index[1]
        xdc_B_2_mini_dianya_dc_name = xdc_B_2_response_json[xdc_B_2_mini_dianya_index]['devicePropertyName']
        xdc_B_2_mini_dianya_neizu = xdc_B_2_response_json[xdc_B_2_mini_dianya_index + 80]['currentValue']
        xdc_B_2_mini_dianya_sn = xdc_B_2_mini_dianya_dc_name[:6]
        print(f"{xdc_B_2_mini_dianya_value}，{xdc_B_2_mini_dianya_sn}，{xdc_B_2_mini_dianya_neizu}")

        # 1号楼101机房B模块41-80节蓄电池内阻
        xdc_B_2_shuzu_neizu = xdc_B_2_shuzu_all[80:120]
        # 1号楼101机房B模块41-80节蓄电池最大内阻、索引、最低电压电池编号
        xdc_B_2_max_neizu_value_with_index = max((value, index) for index, value in enumerate(xdc_B_2_shuzu_neizu))
        xdc_B_2_max_neizu_value = xdc_B_2_max_neizu_value_with_index[0]
        xdc_B_2_max_neizu_index = xdc_B_2_max_neizu_value_with_index[1]
        xdc_B_2_max_neizu_dc_name = xdc_B_2_response_json[xdc_B_2_max_neizu_index + 80]['devicePropertyName']
        xdc_B_2_max_neizu_dc_dianya = xdc_B_2_response_json[xdc_B_2_max_neizu_index]['currentValue']
        xdc_B_2_max_neizu_sn = xdc_B_2_max_neizu_dc_name[:6]
        print(f"{xdc_B_2_max_neizu_value}，{xdc_B_2_max_neizu_sn},{xdc_B_2_max_neizu_dc_dianya}")

        # 实时数据接口
        curr_data_url = "http://10.106.134.153:1026/GetDevicePropertiesInPage"

        # 登录信息
        username = "admin"
        password = "Dh!.134qte0"

        headers = {
            "User-Name": username,
            "Password": password
        }

        # 获取1号楼109机房1-40节蓄电池电压、温度、内阻
        xdc_109_1_response = requests.post(curr_data_url, json={"serverCode": "zgkon", "userId": 0, "pageId": 35},
                                           headers=headers)
        xdc_109_1_shuzu_all = []
        xdc_109_1_response_json = xdc_109_1_response.json()
        for a in xdc_109_1_response_json:
            xdc_109_1_shuzu_all.append(a['currentValue'])

        # 1号楼109机房1-40节蓄电池电压
        xdc_109_1_shuzu_dianya = xdc_109_1_shuzu_all[0:40]
        # 1号楼109机房1-40节蓄电池最低电压、索引、最低电压电池编号
        xdc_109_1_mini_dianya_value_with_index = min(
            (value, index) for index, value in enumerate(xdc_109_1_shuzu_dianya))
        xdc_109_1_mini_dianya_value = xdc_109_1_mini_dianya_value_with_index[0]
        xdc_109_1_mini_dianya_index = xdc_109_1_mini_dianya_value_with_index[1]
        xdc_109_1_mini_dianya_dc_name = xdc_109_1_response_json[xdc_109_1_mini_dianya_index]['devicePropertyName']
        xdc_109_1_mini_dianya_neizu = xdc_109_1_response_json[xdc_109_1_mini_dianya_index + 80]['currentValue']
        xdc_109_1_mini_dianya_sn = xdc_109_1_mini_dianya_dc_name[:6]
        print(f"{xdc_109_1_mini_dianya_value},{xdc_109_1_mini_dianya_sn},{xdc_109_1_mini_dianya_neizu}")

        # 1号楼109机房1-40节蓄电池内阻
        xdc_109_1_shuzu_neizu = xdc_109_1_shuzu_all[80:120]
        # 1号楼109机房1-40节蓄电池最大内阻、索引、最低电压电池编号
        xdc_109_1_max_neizu_value_with_index = max((value, index) for index, value in enumerate(xdc_109_1_shuzu_neizu))
        xdc_109_1_max_neizu_value = xdc_109_1_max_neizu_value_with_index[0]
        xdc_109_1_max_neizu_index = xdc_109_1_max_neizu_value_with_index[1]
        xdc_109_1_max_neizu_dc_name = xdc_109_1_response_json[xdc_109_1_max_neizu_index + 80]['devicePropertyName']
        xdc_109_1_max_neizu_dc_dianya = xdc_109_1_response_json[xdc_109_1_max_neizu_index]['currentValue']
        xdc_109_1_max_neizu_sn = xdc_109_1_max_neizu_dc_name[:6]
        print(f"{xdc_109_1_max_neizu_value}，{xdc_109_1_max_neizu_sn},{xdc_109_1_max_neizu_dc_dianya}")


        return {
            'nckt_wdsd_value': nckt_wdsd_value,
            'bckt_wdsd_value': bckt_wdsd_value,
            'max_wd': max_wd,
            'avg_wd': avg_wd,
            'max_sd': max_sd,
            'avg_sd': avg_sd,
            'UPSB_gdzt_value': UPSB_gdzt_value,
            'UPSB_bdsj_value': UPSB_bdsj_value,
            'UPSB_dcdy_value': UPSB_dcdy_value,
            'dianchi_nance_B_soh_value': dianchi_nance_B_soh_value,
            'UPSB_syrl_value': UPSB_syrl_value,
            'UPSA_gdzt_value': UPSA_gdzt_value,
            'UPSA_bdsj_value': UPSA_bdsj_value,
            'UPSA_dcdy_value': UPSA_dcdy_value,
            'dianchi_nance_A_soh_value': dianchi_nance_A_soh_value,
            'UPSA_syrl_value': UPSA_syrl_value,
            'alarm_value': alarm_value,
            'UPS_beice_gdzt_value': UPS_beice_gdzt_value,
            'UPS_beice_bdsj_value': UPS_beice_bdsj_value,
            'UPS_beice_dcdy_value': UPS_beice_dcdy_value,
            'dianchi_beice_soh_value': dianchi_beice_soh_value,
            'UPS_beice_syrl_value': UPS_beice_syrl_value,
            # 电池组信息
            'xdc_A_32_min_v': xdc_A_32_min_v,
            'xdc_A_32_min_v_sn': xdc_A_32_min_v_sn,
            'xdc_A_32_min_v_dz': xdc_A_32_min_v_dz,
            'xdc_A_160_min_dz': xdc_A_160_min_dz,
            'xdc_A_160_min_dz_sn': xdc_A_160_min_dz_sn,
            'xdc_A_160_min_dz_v': xdc_A_160_min_dz_v,
            'xdc_A_64_min_v': xdc_A_64_min_v,
            'xdc_A_64_min_v_sn': xdc_A_64_min_v_sn,
            'xdc_A_64_min_v_dz': xdc_A_64_min_v_dz,
            'xdc_A_192_min_dz': xdc_A_192_min_dz,
            'xdc_A_192_min_dz_sn': xdc_A_192_min_dz_sn,
            'xdc_A_192_min_dz_v': xdc_A_192_min_dz_v,
            'xdc_B_1_mini_dianya_value': xdc_B_1_mini_dianya_value,
            'xdc_B_1_mini_dianya_sn': xdc_B_1_mini_dianya_sn,
            'xdc_B_1_mini_dianya_neizu': xdc_B_1_mini_dianya_neizu,
            'xdc_B_1_max_neizu_value': xdc_B_1_max_neizu_value,
            'xdc_B_1_max_neizu_sn': xdc_B_1_max_neizu_sn,
            'xdc_B_1_max_neizu_dc_dianya': xdc_B_2_max_neizu_dc_dianya,
            'xdc_B_2_mini_dianya_value': xdc_B_2_mini_dianya_value,
            'xdc_B_2_mini_dianya_sn': xdc_B_2_mini_dianya_sn,
            'xdc_B_2_mini_dianya_neizu': xdc_B_2_mini_dianya_neizu,
            'xdc_B_2_max_neizu_value': xdc_B_2_max_neizu_value,
            'xdc_B_2_max_neizu_sn': xdc_B_2_max_neizu_sn,
            'xdc_B_2_max_neizu_dc_dianya': xdc_B_2_max_neizu_dc_dianya,
            'xdc_109_1_mini_dianya_value': xdc_109_1_mini_dianya_value,
            'xdc_109_1_mini_dianya_sn': xdc_109_1_mini_dianya_sn,
            'xdc_109_1_mini_dianya_neizu': xdc_109_1_mini_dianya_neizu,
            'xdc_109_1_max_neizu_value': xdc_109_1_max_neizu_value,
            'xdc_109_1_max_neizu_sn': xdc_109_1_max_neizu_sn,
            'xdc_109_1_max_neizu_dc_dianya': xdc_109_1_max_neizu_dc_dianya,
        }
    else:
        print("登录失败！")
get_datacenter_11haolou_data()